package BasicPractice

//Scala初试
object printPractice {
  /* def main(args: Array[String]): Unit = {
     for{i <-1 to 10}
       println(i)
   }
   程序将数字1至10分配给变量，然后执行println（i），打印数字1至10。*/

  /*  def main(args: Array[String]): Unit = {
      for {
        i <- 1 to 10
        j <- 1 to 10
      }
        println(i * j)
    }*/

  class Person(val name: String, var age: Int)

  //Scala变量声明
  def main(args: Array[String]): Unit = {
    val array: Array[String] = new Array(5)
    //array = new Array(2)
    array(0) = "Hello"
    println(array(0))

    var stockPrice:Double = 100.0
    stockPrice = 200.0
    println(stockPrice)
    //可变变量用关键字 var 声明，并且必须立即初始化。

    val p = new Person("Wang",20)
    println(p.name)
    println(p.age)
    p.age = 30
    println(p.age)

  }


}
